<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>求一组数中的所有数的和和平均值</title>
</head>

<body>
    <script>
        var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
        var sum = 0;
        var average = 0;
        for (var i = 0, len = arr.length; i < len; i++) {
            sum += arr[i];
        }
        console.log("这组数的和为："+sum+"，平均值为："+sum/len);
    </script>
</body>

</html>